#ifndef PRINTER_H_
#define PRINTER_H_

#include "String.h"

class Printer
{
private:
	static String NEW_LINE;

protected:
	virtual void doprint(String& in) = 0;

public:
	virtual ~Printer(){}

	virtual void print(const ToStringConvertible& in)
	{
		String tmp = ((ToStringConvertible*)(void*)&in)->toString();
		doprint(tmp);
	}

	virtual void println(const ToStringConvertible& in)
	{
		print(in);
		print(NEW_LINE);
	}

	virtual void operator<<(const ToStringConvertible& in) {println(in);}
};

#endif /* PRINTER_H_ */
